<% layout('/layouts/default.html', {title: '学生信息管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('学生信息管理')}
			</div>
			<div class="box-tools pull-right">

				<a href="${ctx}/student/student/exportEmptyStudentExcel"><i class="glyphicon glyphicon-import"></i> ${text('下载学生表模板')}</a><span>&nbsp&nbsp</span><span>&nbsp&nbsp</span>

				<a href="javascript:" id="btnImport"><i class="glyphicon glyphicon-export"></i> ${text('通过Excel批量导入学生信息')}</a>

				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('student:student:edit')){ %>
					<a href="${ctx}/student/student/form" class="btn btn-default btnTool" title="${text('新增学生表')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${student}" action="${ctx}/student/student/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('学生id')}：</label>
				</div>
				<div class="form-group">
					<label class="control-label">${text('学生姓名')}：</label>
					<div class="control-inline">
						<#form:input path="studentName" maxlength="20" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('学生性别')}：</label>
					<div class="control-inline">
						<#form:input path="studentSex" maxlength="2" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('手机号码')}：</label>
					<div class="control-inline">
						<#form:input path="studentNumber" maxlength="16" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("学生id")}', name:'studentId', index:'a.student_id', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/student/student/form?studentId='+row.studentId+'" class="btnList" data-title="${text("编辑学生表")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("学生姓名")}', name:'studentName', index:'a.student_name', width:150, align:"left"},
		{header:'${text("学生性别")}', name:'studentSex', index:'a.student_sex', width:150, align:"left"},
		{header:'${text("手机号码")}', name:'studentNumber', index:'a.student_number', width:150, align:"left"},
		{header:'${text("操作")}', name:'actions', width:120, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('student:student:edit')){ %>
				actions.push('<a href="${ctx}/student/student/form?studentId='+row.studentId+'" class="btnList" title="${text("编辑学生表")}"><i class="fa fa-pencil"></i></a>&nbsp;');
				actions.push('<a href="${ctx}/student/student/delete?studentId='+row.studentId+'" class="btnList" title="${text("删除学生表")}" data-confirm="${text("确认要删除该学生表吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
$('#btnImport').click(function(){
	js.layer.open({
		type: 1,
		area: ['400px'],
		title: '${text("通过Excel批量导入学生信息")}',
		resize: false,
		scrollbar: true,
		content: js.template('importTpl'),
		success: function(layero, index){
			layero.find('input[type="checkbox"]').iCheck();
		},
		btn: ['<i class="fa fa-check"></i> ${text("导入")}',
			'<i class="fa fa-remove"></i> ${text("关闭")}'],
		btn1: function(index, layero){
			var form = {
				inputForm: layero.find('#inputForm'),
				file: layero.find('#file').val()
			};
			if (form.file == '' || (!js.endWith(form.file, '.xls') && !js.endWith(form.file, '.xlsx'))){
				js.showMessage("${text('文件不正确，请选择后缀为“xls”或“xlsx”的文件。')}", null, 'warning');
				return false;
			}
			js.ajaxSubmitForm(form.inputForm, function(data){
				js.showMessage(data.message);
				if(data.result == Global.TRUE){
					js.layer.closeAll();
				}
				page();
			}, "json");
			return true;
		}
	});
});
</script>
<script id="importTpl" type="text/template">//<!--
<form id="inputForm" action="${ctx}/student/student/importData" method="post" enctype="multipart/form-data"
	class="form-horizontal mt20 mb10" style="overflow:auto;max-height:200px;">
	<div class="row">
		<div class="col-xs-12 col-xs-offset-1">
			<input type="file" id="file" name="file" class="form-file"/>
			<div class="mt10 pt5">
				<#form:label name="updateSupport" label="${text('请下载学生表模板再导入学生信息')}" class="form-control"
					title="${text('请下载学生表模板再导入学生信息')}"/> 请下载学生表模板 &nbsp&nbsp 再导入学生信息&nbsp;
				<a href="${ctx}/student/student/exportEmptyStudentExcel" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> ${text('下载模板')}</a>
			</div>
			<font color="red" class="pull-left mt10">
				${text('提示：仅允许导入“xls”或“xlsx”格式文件！')}
			</font>
		</div>
	</div>
</form>
//--></script>